Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modules settings persistence between updates #4359

Merged
merged 5 commits into from
Aug 5, 2022

Conversation

Desvelao
Copy link
Member

@Desvelao Desvelao commented Jul 26, 2022

Description

This PR fixes that the host extension configuration was lost when changing the installed plugin (changed version or revision) because the registry file was rebuilt with an empty configuration for the hosts field. Now, the hosts configuration is kept and migrates the extension configuration when changing the installed plugin.

Extension configuration migration:

  • Keep the supported and existing extension with the configured value.
  • Add the supported and missing extensions in the previous configuration
  • Remove not supported extensions by the installed plugin

Changes

  • Migrated the existing host configuration in the registry file when changing the
    plugin version or revision, instead of removing it when it was rebuilt.
  • Removed not necessary return statements
  • Removed not necessary try/catch block
  • Improved logging
  • Created tests for the migration registry file

Test

Manual

  • Same plugin version and revision, restart the plugin platform. The registry file should not be changed.
  • Different plugin version or revision, restart the plugin platform. The registry file should be rebuilt and keeps the host configuration.
  • Different plugin version or revision, removes some extension of any host in the registry file, restart the plugin platform. The registry file should be rebuilt and keeps the host configuration. The removed extension should be included in the host and have the default value.

Automatic

A new test file was created. Run the test with:

# in the plugin root directory
yarn test:jest server/start/initialize/index.test.ts

…y file when changing the plugin version or revision

- Migrated the existent host configuration in the registry file when changing the
  plugin version or revision instead of remove it when it was rebuilt.
- Removed not necessary return statements
- Removed not necessary try/catch block
- Added some logs
- Enhanced some log messages
- Created tests for the migration registry file
@Desvelao Desvelao self-assigned this Jul 26, 2022
@Desvelao Desvelao linked an issue Jul 26, 2022 that may be closed by this pull request
@Desvelao Desvelao changed the title fix the host extension configuration was set to default when changing the plugin version or revision fix the host extensions configuration was set to default when changing the plugin version or revision Jul 26, 2022
@AlexRuiz7 AlexRuiz7 changed the title fix the host extensions configuration was set to default when changing the plugin version or revision Fix modules settings persistence between updates Jul 27, 2022
Copy link
Member

@yenienserrano yenienserrano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ✅

image

Copy link
Member

@Machi3mfl Machi3mfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test ✅
CR ✅

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

Jest Test Coverage % values
Statements 6.84% ( 2493 / 36461 )
Branches 2.72% ( 768 / 28219 )
Functions 4.58% ( 408 / 8914 )
Lines 6.92% ( 2413 / 34886 )

@Desvelao Desvelao merged commit 3e056c5 into 4.3-7.10 Aug 5, 2022
@Desvelao Desvelao deleted the fix/4179-migrate-extensions-registry-file branch August 5, 2022 07:12
github-actions bot pushed a commit that referenced this pull request Aug 5, 2022
* fix(plugin-initialize): migrate the host configuration in the registry file when changing the plugin version or revision

- Migrated the existent host configuration in the registry file when changing the
  plugin version or revision instead of remove it when it was rebuilt.
- Removed not necessary return statements
- Removed not necessary try/catch block
- Added some logs
- Enhanced some log messages
- Created tests for the migration registry file

* changelog: add PR entry

* changelog: removed new line

Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 3e056c5)
@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

The backport to 4.3-1.2-wzd failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-4.3-1.2-wzd 4.3-1.2-wzd
# Navigate to the new working tree
cd .worktrees/backport-4.3-1.2-wzd
# Create a new branch
git switch --create backport-4359-to-4.3-1.2-wzd
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 3e056c59a177bc332437d1503e4b26a3a65ae79e
# Push it to GitHub
git push --set-upstream origin backport-4359-to-4.3-1.2-wzd
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-4.3-1.2-wzd

Then, create a pull request where the base branch is 4.3-1.2-wzd and the compare/head branch is backport-4359-to-4.3-1.2-wzd.

Desvelao added a commit that referenced this pull request Aug 5, 2022
…4384)

Fix modules settings persistence between updates (#4359)

* fix(plugin-initialize): migrate the host configuration in the registry file when changing the plugin version or revision

- Migrated the existent host configuration in the registry file when changing the
  plugin version or revision instead of remove it when it was rebuilt.
- Removed not necessary return statements
- Removed not necessary try/catch block
- Added some logs
- Enhanced some log messages
- Created tests for the migration registry file

* changelog: add PR entry

* changelog: removed new line

Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 3e056c5)

Co-authored-by: Antonio <34042064+Desvelao@users.noreply.github.com>
Desvelao added a commit that referenced this pull request Aug 5, 2022
* fix(plugin-initialize): migrate the host configuration in the registry file when changing the plugin version or revision

- Migrated the existent host configuration in the registry file when changing the
  plugin version or revision instead of remove it when it was rebuilt.
- Removed not necessary return statements
- Removed not necessary try/catch block
- Added some logs
- Enhanced some log messages
- Created tests for the migration registry file

* changelog: add PR entry

* changelog: removed new line

Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 3e056c5)
Desvelao added a commit that referenced this pull request Aug 5, 2022
…es (#4385)

Fix modules settings persistence between updates (#4359)

* fix(plugin-initialize): migrate the host configuration in the registry file when changing the plugin version or revision

- Migrated the existent host configuration in the registry file when changing the
  plugin version or revision instead of remove it when it was rebuilt.
- Removed not necessary return statements
- Removed not necessary try/catch block
- Added some logs
- Enhanced some log messages
- Created tests for the migration registry file

* changelog: add PR entry

* changelog: removed new line

Co-authored-by: Álex <alejandro.ruiz.becerra@wazuh.com>
(cherry picked from commit 3e056c5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Module settings are not persistent between updates
4 participants